package cn.sixmillions.yuqueblog.utils;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;

/**
 * html工具类
 */
public class HtmlUtil {

    /**
     * 重写图片连接
     *
     * @param html
     * @return
     */
    public static String overwriteImgSrc(String html) {
        Document document = Jsoup.parse(html);
        document.getElementsByTag("img").forEach(e -> {
            if (e.attr("src").startsWith("http")) {
                e.attr("src", "/api/image?url=" + e.attr("src"));
            }
        });
        return document.html();
    }

    public static void main(String[] args) {
       
    }
}
